home *** CD-ROM | disk | FTP | other *** search
/ Mac OS on the PowerPC Mic…rocessor - In Store Demo / Mac OS on the PowerPC Microprocessor.iso / MacOS / MacOS.dxr / 00099_120_Index_grid_script.ls < prev    next >
Encoding:
Text File  |  1996-05-13  |  3.8 KB  |  95 lines

  1. property iOriginX, iOriginY, iButtonSize, iButtonArea, iButtonAreaRect, iOffsetLeft, iOffsetTop, iButtonRectList, iButtonOrigin, iPreviousSelectedKeyword
  2. global theSparkle, theBlitPict, objIndexBtn, objBookmark, gallchapterlist, gIndexParagraphField, gGraphicPath, gFileName, gSpriteSetList, gNextPlay, gQuick, gKeywordDataList, gSelLine
  3.  
  4. on birth me
  5.   set iButtonSize to 12
  6.   set tMaxH to 27
  7.   set tMaxV to 23
  8.   set iOriginX to 151
  9.   set iOriginY to 114
  10.   set iButtonArea to iOriginX & "," & iOriginY & "," & iOriginX + (iButtonSize * tMaxH) & "," & iOriginY + (iButtonSize * tMaxV)
  11.   set iButtonAreaRect to BoxToRect(iButtonArea)
  12.   set iOffsetLeft to iOriginX - iButtonSize
  13.   set iOffsetTop to iOriginY - iButtonSize
  14.   set iButtonOrigin to rect(iOffsetLeft, iOffsetTop, iOriginX, iOriginY)
  15.   set pictfilepath to gGraphicPath & getProp(gFileName, #INDEXBTN)
  16.   blitPictInitFile(objIndexBtn, pictfilepath)
  17.   set iButtonRectList to [:]
  18.   addProp(iButtonRectList, #NORMAL, "0,0,12,12")
  19.   addProp(iButtonRectList, #VISITED, "324,0,336,12")
  20.   addProp(iButtonRectList, #NORMAL_SELECTED, "336,0,348,12")
  21.   addProp(iButtonRectList, #VISITED_SELECTED, "336,0,348,12")
  22.   set iPreviousSelectedKeyword to gSelLine
  23.   return me
  24. end
  25.  
  26. on mStartIndex me
  27.   repeat with tChapter = 1 to mGetMaxChapter(objBookmark)
  28.     set tMaxParagraphs to mGetMaxParagraph(objBookmark, tChapter)
  29.     mDrawNormalButtons(me, tChapter, tMaxParagraphs)
  30.     repeat with tParagraph = 1 to tMaxParagraphs
  31.       set tButtonStatus to mGetStatus(objBookmark, tChapter, tParagraph)
  32.       if tButtonStatus <> #NORMAL then
  33.         mDrawButton(me, tChapter, tParagraph, tButtonStatus)
  34.       end if
  35.     end repeat
  36.   end repeat
  37. end
  38.  
  39. on mDrawNormalButtons me, tChapterLine, tMaxParagraphs
  40.   set tSrcRect to BoxToRect("0,0," & iButtonSize * tMaxParagraphs & "," & iButtonSize)
  41.   set tDestRect to RectToBox(offset(tSrcRect, iOriginX, iOffsetTop + (tChapterLine * iButtonSize)))
  42.   blitPictDrawScreen(objIndexBtn, RectToBox(tSrcRect), tDestRect, "copy", 0, 0)
  43. end
  44.  
  45. on mDrawButton me, tChapter, tParagraph, tButtonStatus
  46.   set tSrcRect to getaProp(iButtonRectList, tButtonStatus)
  47.   set tDestRect to RectToBox(offset(iButtonOrigin, tParagraph * iButtonSize, tChapter * iButtonSize))
  48.   blitPictDrawScreen(objIndexBtn, tSrcRect, tDestRect, "copy", 0, 0)
  49. end
  50.  
  51. on mDrawKeywords me, tSelectedKeyword
  52.   if iPreviousSelectedKeyword > 0 then
  53.     repeat with keywordData in getAt(gKeywordDataList, iPreviousSelectedKeyword)
  54.       set tChapter to getAt(keywordData, 1)
  55.       set tParagraph to getAt(keywordData, 2)
  56.       set tButtonStatus to mGetStatus(objBookmark, tChapter, tParagraph)
  57.       mDrawButton(me, tChapter, tParagraph, tButtonStatus)
  58.     end repeat
  59.   end if
  60.   set iPreviousSelectedKeyword to tSelectedKeyword
  61.   repeat with keywordData in getAt(gKeywordDataList, tSelectedKeyword)
  62.     set tChapter to getAt(keywordData, 1)
  63.     set tParagraph to getAt(keywordData, 2)
  64.     set tButtonStatus to value("#" & mGetStatus(objBookmark, tChapter, tParagraph) & "_SELECTED")
  65.     mDrawButton(me, tChapter, tParagraph, tButtonStatus)
  66.   end repeat
  67. end
  68.  
  69. on mMouseUp me
  70.   set tParagraph to (getAt(clickLoc(), 1) - iOffsetLeft) / iButtonSize
  71.   set tChapter to (getAt(clickLoc(), 2) - iOffsetTop) / iButtonSize
  72.   if (tChapter > 0) and (tParagraph > 0) and (tChapter <= mGetMaxChapter(objBookmark)) then
  73.     if tParagraph <= mGetMaxParagraph(objBookmark, tChapter) then
  74.       sparkle(theSparkle, clickLoc())
  75.       repeat with tSprite in getAt(gSpriteSetList, 3)
  76.         set the visible of sprite tSprite to 0
  77.       end repeat
  78.       if gQuick then
  79.         set gNextPlay to [tChapter, tParagraph, #play]
  80.       else
  81.         set gNextPlay to [tChapter, tParagraph, #pause]
  82.       end if
  83.       set the mouseDownScript to "playerMouseDownScript"
  84.       go("PlayMode")
  85.     else
  86.       beep()
  87.     end if
  88.   else
  89.     beep()
  90.   end if
  91. end
  92.  
  93. on mRollOver me
  94. end
  95.